package com.net.test.db;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Repository;

import com.net.test.vo.TVO;
import com.net.test.vo.TestVO;


@Repository(value="dao")
public class MybatisDAO {
	SqlSessionFactory ssf = SqlSessionManager.getSqlSession();
	SqlSession ss = null;

	//
	@SuppressWarnings("unchecked")
	public Object getListData(String id) throws Exception {
		
		Object lists = null;
		
		ss = ssf.openSession();	
		
		try {
			lists = ss.selectList(id);
			
			
		} catch (Exception e) {
			System.out.println(e.toString());
			throw e;
		} finally{
			ss.close();
		}
		
		return lists;
	}
	@SuppressWarnings("unchecked")
	public Object getListData(String id, Object obj) throws Exception {
		
		Object lists = null;
		
		ss = ssf.openSession();	
		
		try {
			lists = ss.selectList(id, obj);
			
			
		} catch (Exception e) {
			System.out.println(e.toString());
			throw e;
		} finally{
			ss.close();
		}
		
		return lists;
	}
	@SuppressWarnings("unchecked")
	public Object getListData1(String id, TVO value) throws Exception {
		
		Object lists = null;
		
		ss = ssf.openSession();	
		
		try {
			lists = ss.selectList(id,value);
			
			
		} catch (Exception e) {
			System.out.println(e.toString());
			throw e;
		} finally{
			ss.close();
		}
		
		return lists;
	}
	
	
	@SuppressWarnings("unchecked")
    public Object getViewData(String id, String value) throws Exception {
        
        Object lists = null;
        
        ss = ssf.openSession(); 
        
        try {
            lists = ss.selectOne(id,value);
            
            
        } catch (Exception e) {
            System.out.println(e.toString());
            throw e;
        } finally{
            ss.close();
        }
        
        return lists;
    }
	
	@SuppressWarnings("unchecked")
    public Object getViewData1(String id, TVO check1) throws Exception {        
        Object lists = "";
        
        ss = ssf.openSession(); 
        
        try {
            lists = ss.selectOne(id,check1);
            
            
        } catch (Exception e) {
            System.out.println(e.toString());
            throw e;
        } finally{
            ss.close();
        }
        
        return lists;
    }
	@SuppressWarnings("unchecked")
    public Object getViewDataOne(String id, String value) throws Exception {
        
        Object lists = null;
        
        ss = ssf.openSession(); 
        
        try {
            lists = ss.selectOne(id,value);
            
            
        } catch (Exception e) {
            System.out.println(e.toString());
            throw e;
        } finally{
            ss.close();
        }
        
        return lists;
    }
	@SuppressWarnings("unchecked")
	public Object getViewDataOne(String id, Object value) throws Exception {
		
		Object lists = null;
		
		ss = ssf.openSession(); 
		
		try {
			lists = ss.selectOne(id,value);
			
			
		} catch (Exception e) {
			System.out.println(e.toString());
			throw e;
		} finally{
			ss.close();
		}
		
		return lists;
	}
	@SuppressWarnings("unchecked")
	public Object getViewDataOne(String id) throws Exception {
		
		Object lists = null;
		
		ss = ssf.openSession(); 
		
		try {
			lists = ss.selectOne(id);
			
			
		} catch (Exception e) {
			System.out.println(e.toString());
			throw e;
		} finally{
			ss.close();
		}
		
		return lists;
	}
	@SuppressWarnings("unchecked")
    public Object getViewDataOne(String id, TestVO value) throws Exception {
        
        Object lists = null;
        
        ss = ssf.openSession(); 
        
        try {
            lists = ss.selectOne(id,value);
            
            
        } catch (Exception e) {
            System.out.println(e.toString());
            throw e;
        } finally{
            ss.close();
        }
        
        return lists;
    }
	@SuppressWarnings("unchecked")
    public Object getViewDataOne(String id, TVO value) throws Exception {
        
        Object lists = null;
        
        ss = ssf.openSession(); 
        
        try {
            lists = ss.selectOne(id,value);
            
            
        } catch (Exception e) {
            System.out.println(e.toString());
            throw e;
        } finally{
            ss.close();
        }
        
        return lists;
    }
	@SuppressWarnings("unchecked")
    public Object getViewDataOne2(String id, TVO value) throws Exception {
        
        Object lists = null;
        
        ss = ssf.openSession(); 
        
        try {
            lists = ss.selectOne(id,value);
            
            
        } catch (Exception e) {
            System.out.println(e.toString());
            throw e;
        } finally{
            ss.close();
        }
        
        return lists;
    }
	
	@SuppressWarnings("unchecked")
	public int insertData(String id, Object obj) throws Exception {
		
		int result = 0;
		
		ss = ssf.openSession();	
		
		try {
			result = ss.insert(id, obj);
			ss.commit();
			
		} catch (Exception e) {
			System.out.println(e.toString());
			throw e;
		} finally{
			ss.close();
		}
		
		return result;
	}
	@SuppressWarnings("unchecked")
	public int insertData1(String id, TVO obj) throws Exception {
		
		int result = 0;
		
		ss = ssf.openSession();	
		
		try {
			result = ss.insert(id, obj);
			ss.commit();
			
		} catch (Exception e) {
			System.out.println(e.toString());
			throw e;
		} finally{
			ss.close();
		}
		
		return result;
	}
	@SuppressWarnings("unchecked")
    public int updateData(String id, Object obj) throws Exception {
        
        int result = 0;
        
        ss = ssf.openSession(); 
        
        try {
            result = ss.update(id, obj);
            ss.commit();
            
        } catch (Exception e) {
            System.out.println(e.toString());
            throw e;
        } finally{
            ss.close();
        }
        
        return result;
    }
	
	@SuppressWarnings("unchecked")
    public int updateData1(String id, TestVO obj) throws Exception {
        
        int result = 0;
        
        ss = ssf.openSession(); 
        
        try {
            result = ss.update(id, obj);
            ss.commit();
            
        } catch (Exception e) {
            System.out.println(e.toString());
            throw e;
        } finally{
            ss.close();
        }
        
        return result;
    }
	@SuppressWarnings("unchecked")
    public int updateData2(String id, TVO obj) throws Exception {
        
        int result = 0;
        
        ss = ssf.openSession(); 
        
        try {
            result = ss.update(id, obj);
            ss.commit();
            
        } catch (Exception e) {
            System.out.println(e.toString());
            throw e;
        } finally{
            ss.close();
        }
        
        return result;
    }
	@SuppressWarnings("unchecked")
    public int updateData3(String id, TVO obj) throws Exception {
        
        int result = 0;
        
        ss = ssf.openSession(); 
        
        try {
            result = ss.update(id, obj);
            ss.commit();
            
        } catch (Exception e) {
            System.out.println(e.toString());
            throw e;
        } finally{
            ss.close();
        }
        
        return result;
    }
	
	
	@SuppressWarnings("unchecked")
    public int deleteData(String id, Object obj) throws Exception {
        
        int result = 0;
        
        ss = ssf.openSession(); 
        
        try {
            result = ss.delete(id, obj);
            ss.commit();
            
        } catch (Exception e) {
            System.out.println(e.toString());
            throw e;
        } finally{
            ss.close();
        }
        
        return result;
    }
	@SuppressWarnings("unchecked")
    public int deleteData1(String id, TVO obj) throws Exception {
        
        int result = 0;
        
        ss = ssf.openSession(); 
        
        try {
            result = ss.delete(id, obj);
            ss.commit();
            
        } catch (Exception e) {
            System.out.println(e.toString());
            throw e;
        } finally{
            ss.close();
        }
        
        return result;
    }
}
